/*     */ package com.openbravo.pos.forms;
/*     */ 
/*     */ import com.openbravo.data.loader.LocalRes;
/*     */ import com.openbravo.pos.ticket.UserInfo;
/*     */ import com.openbravo.pos.util.Hashcypher;

/*     */ import java.io.IOException;
/*     */ import java.io.StringReader;
/*     */ import java.util.HashMap;
/*     */ import java.util.HashSet;
/*     */ import java.util.Set;
/*     */ import java.util.logging.Level;
/*     */ import java.util.logging.Logger;

/*     */ import javax.swing.Icon;
/*     */ import javax.xml.parsers.ParserConfigurationException;
/*     */ import javax.xml.parsers.SAXParser;
/*     */ import javax.xml.parsers.SAXParserFactory;

/*     */ import org.xml.sax.Attributes;
/*     */ import org.xml.sax.InputSource;
/*     */ import org.xml.sax.SAXException;
/*     */ import org.xml.sax.helpers.DefaultHandler;
/*     */ 
/*     */ public class AppUser
/*     */ {
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
/*  45 */   private static Logger logger = Logger.getLogger("com.openbravo.pos.forms.AppUser");
/*     */ 
/*  47 */   private static SAXParser m_sp = null;
/*     */   private static HashMap<String, String> m_oldclasses;
/*     */   private String m_sId;
/*     */   private String m_sName;
/*     */   private String m_sCard;
/*     */   private String m_sPassword;
/*     */   private String m_sRole;
/*     */   private Icon m_Icon;
/*     */   private Set<String> m_apermissions;
/*     */ 
/*     */   public AppUser(String id, String name, String password, String card, String role, Icon icon)
/*     */   {
/*  65 */     this.m_sId = id;
/*  66 */     this.m_sName = name;
/*  67 */     this.m_sPassword = password;
/*  68 */     this.m_sCard = card;
/*  69 */     this.m_sRole = role;
/*  70 */     this.m_Icon = icon;
/*  71 */     this.m_apermissions = null;
/*     */   }
/*     */ 
/*     */   public Icon getIcon() {
/*  75 */     return this.m_Icon;
/*     */   }
/*     */ 
/*     */   public String getId() {
/*  79 */     return this.m_sId;
/*     */   }
/*     */ 
/*     */   public String getName() {
/*  83 */     return this.m_sName;
/*     */   }
/*     */ 
/*     */   public void setPassword(String sValue) {
/*  87 */     this.m_sPassword = sValue;
/*     */   }
/*     */ 
/*     */   public String getPassword() {
/*  91 */     return this.m_sPassword;
/*     */   }
/*     */ 
/*     */   public String getRole() {
/*  95 */     return this.m_sRole;
/*     */   }
/*     */ 
/*     */   public String getCard() {
/*  99 */     return this.m_sCard;
/*     */   }
/*     */ 
/*     */   public boolean authenticate() {
/* 103 */     return (this.m_sPassword == null) || (this.m_sPassword.equals("")) || (this.m_sPassword.startsWith("empty:"));
/*     */   }
/*     */   public boolean authenticate(String sPwd) {
/* 106 */     return Hashcypher.authenticate(sPwd, this.m_sPassword);
/*     */   }







/*     */ 
/*     */   public void fillPermissions(DataLogicSystem dlSystem)
/*     */   {
/* 112 */     this.m_apermissions = new HashSet();
/*     */ 
/* 114 */     this.m_apermissions.add("com.openbravo.pos.forms.JPanelMenu");
/* 115 */     this.m_apermissions.add("Menu.Exit");
/*     */ 
/* 117 */     String sRolePermisions = dlSystem.findRolePermissions(this.m_sRole);
/*     */ 
/* 119 */     if (sRolePermisions != null)
/*     */       try {
/* 121 */         if (m_sp == null) {
/* 122 */           SAXParserFactory spf = SAXParserFactory.newInstance();
/* 123 */           m_sp = spf.newSAXParser();
/*     */         }
/* 125 */         m_sp.parse(new InputSource(new StringReader(sRolePermisions)), new ConfigurationHandler());
/*     */       }
/*     */       catch (ParserConfigurationException ePC) {
/* 128 */         logger.log(Level.WARNING, LocalRes.getIntString("exception.parserconfig"), ePC);
/*     */       } catch (SAXException eSAX) {
/* 130 */         logger.log(Level.WARNING, LocalRes.getIntString("exception.xmlfile"), eSAX);
/*     */       } catch (IOException eIO) {
/* 132 */         logger.log(Level.WARNING, LocalRes.getIntString("exception.iofile"), eIO);
/*     */       }
/*     */   }
/*     */ 
/*     */   public boolean hasPermission(String classname)
/*     */   {
/* 140 */     return this.m_apermissions == null ? false : this.m_apermissions.contains(classname);
/*     */   }
/*     */ 
/*     */   public UserInfo getUserInfo() {
/* 144 */     return new UserInfo(this.m_sId, this.m_sName);
/*     */   }
/*     */ 
/*     */   private static String mapNewClass(String classname) {
/* 148 */     String newclass = (String)m_oldclasses.get(classname);
/* 149 */     return newclass == null ? classname : newclass;
/*     */   }
/*     */ 
/*     */   private static void initOldClasses()
/*     */   {
/* 155 */     m_oldclasses = new HashMap();
/*     */ 
/* 158 */     m_oldclasses.put("net.adrianromero.tpv.panelsales.JPanelTicketSales", "com.openbravo.pos.sales.JPanelTicketSales");
/* 159 */     m_oldclasses.put("net.adrianromero.tpv.panelsales.JPanelTicketEdits", "com.openbravo.pos.sales.JPanelTicketEdits");
/* 160 */     m_oldclasses.put("net.adrianromero.tpv.panels.JPanelPayments", "com.openbravo.pos.panels.JPanelPayments");
/* 161 */     m_oldclasses.put("net.adrianromero.tpv.panels.JPanelCloseMoney", "com.openbravo.pos.panels.JPanelCloseMoney");
/* 162 */     m_oldclasses.put("net.adrianromero.tpv.reports.JReportClosedPos", "/com/openbravo/reports/closedpos.bs");
/*     */ 
/* 175 */     m_oldclasses.put("Menu.StockManagement", "com.openbravo.pos.forms.MenuStockManagement");
/* 176 */     m_oldclasses.put("net.adrianromero.tpv.inventory.ProductsPanel", "com.openbravo.pos.inventory.ProductsPanel");
/* 177 */     m_oldclasses.put("net.adrianromero.tpv.inventory.ProductsWarehousePanel", "com.openbravo.pos.inventory.ProductsWarehousePanel");
/* 178 */     m_oldclasses.put("net.adrianromero.tpv.inventory.CategoriesPanel", "com.openbravo.pos.inventory.CategoriesPanel");
/* 179 */     m_oldclasses.put("net.adrianromero.tpv.panels.JPanelTax", "com.openbravo.pos.inventory.TaxPanel");
/* 180 */     m_oldclasses.put("net.adrianromero.tpv.inventory.StockDiaryPanel", "com.openbravo.pos.inventory.StockDiaryPanel");
/* 181 */     m_oldclasses.put("net.adrianromero.tpv.inventory.StockManagement", "com.openbravo.pos.inventory.StockManagement");
/* 182 */     m_oldclasses.put("net.adrianromero.tpv.reports.JReportProducts", "/com/openbravo/reports/products.bs");
/* 183 */     m_oldclasses.put("net.adrianromero.tpv.reports.JReportCatalog", "/com/openbravo/reports/productscatalog.bs");
/* 184 */     m_oldclasses.put("net.adrianromero.tpv.reports.JReportInventory", "/com/openbravo/reports/inventory.bs");
/* 185 */     m_oldclasses.put("net.adrianromero.tpv.reports.JReportInventory2", "/com/openbravo/reports/inventoryb.bs");
/* 186 */     m_oldclasses.put("net.adrianromero.tpv.reports.JReportInventoryBroken", "/com/openbravo/reports/inventorybroken.bs");
/* 187 */     m_oldclasses.put("net.adrianromero.tpv.reports.JReportInventoryDiff", "/com/openbravo/reports/inventorydiff.bs");
/*     */ 
/* 189 */     m_oldclasses.put("Menu.SalesManagement", "com.openbravo.pos.forms.MenuSalesManagement");
/* 190 */     m_oldclasses.put("net.adrianromero.tpv.reports.JReportUserSales", "/com/openbravo/reports/usersales.bs");
/* 191 */     m_oldclasses.put("net.adrianromero.tpv.reports.JReportClosedProducts", "/com/openbravo/reports/closedproducts.bs");
/* 192 */     m_oldclasses.put("net.adrianromero.tpv.reports.JReportTaxes", "/com/openbravo/reports/taxes.bs");
/* 193 */     m_oldclasses.put("net.adrianromero.tpv.reports.JChartSales", "/com/openbravo/reports/chartsales.bs");
/*     */ 
/* 195 */     m_oldclasses.put("Menu.Maintenance", "com.openbravo.pos.forms.MenuMaintenance");
/* 196 */     m_oldclasses.put("net.adrianromero.tpv.admin.PeoplePanel", "com.openbravo.pos.admin.PeoplePanel");
/* 197 */     m_oldclasses.put("net.adrianromero.tpv.admin.RolesPanel", "com.openbravo.pos.admin.RolesPanel");
/* 198 */     m_oldclasses.put("net.adrianromero.tpv.admin.ResourcesPanel", "com.openbravo.pos.admin.ResourcesPanel");
/* 199 */     m_oldclasses.put("net.adrianromero.tpv.inventory.LocationsPanel", "com.openbravo.pos.inventory.LocationsPanel");
/* 200 */     m_oldclasses.put("net.adrianromero.tpv.mant.JPanelFloors", "com.openbravo.pos.mant.JPanelFloors");
/* 201 */     m_oldclasses.put("net.adrianromero.tpv.mant.JPanelPlaces", "com.openbravo.pos.mant.JPanelPlaces");
/* 202 */     m_oldclasses.put("com.openbravo.possync.ProductsSync", "com.openbravo.possync.ProductsSyncCreate");
/* 203 */     m_oldclasses.put("com.openbravo.possync.OrdersSync", "com.openbravo.possync.OrdersSyncCreate");
/*     */ 
/* 205 */     m_oldclasses.put("Menu.ChangePassword", "Menu.ChangePassword");
/* 206 */     m_oldclasses.put("net.adrianromero.tpv.panels.JPanelPrinter", "com.openbravo.pos.panels.JPanelPrinter");
/* 207 */     m_oldclasses.put("net.adrianromero.tpv.config.JPanelConfiguration", "com.openbravo.pos.config.JPanelConfiguration");
/*     */ 
/* 213 */     m_oldclasses.put("com.openbravo.pos.reports.JReportCustomers", "/com/openbravo/reports/customers.bs");
/* 214 */     m_oldclasses.put("com.openbravo.pos.reports.JReportCustomersB", "/com/openbravo/reports/customersb.bs");
/* 215 */     m_oldclasses.put("com.openbravo.pos.reports.JReportClosedPos", "/com/openbravo/reports/closedpos.bs");
/* 216 */     m_oldclasses.put("com.openbravo.pos.reports.JReportClosedProducts", "/com/openbravo/reports/closedproducts.bs");
/* 217 */     m_oldclasses.put("com.openbravo.pos.reports.JChartSales", "/com/openbravo/reports/chartsales.bs");
/* 218 */     m_oldclasses.put("com.openbravo.pos.reports.JReportInventory", "/com/openbravo/reports/inventory.bs");
/* 219 */     m_oldclasses.put("com.openbravo.pos.reports.JReportInventory2", "/com/openbravo/reports/inventoryb.bs");
/* 220 */     m_oldclasses.put("com.openbravo.pos.reports.JReportInventoryBroken", "/com/openbravo/reports/inventorybroken.bs");
/* 221 */     m_oldclasses.put("com.openbravo.pos.reports.JReportInventoryDiff", "/com/openbravo/reports/inventorydiff.bs");
/* 222 */     m_oldclasses.put("com.openbravo.pos.reports.JReportPeople", "/com/openbravo/reports/people.bs");
/* 223 */     m_oldclasses.put("com.openbravo.pos.reports.JReportTaxes", "/com/openbravo/reports/taxes.bs");
/* 224 */     m_oldclasses.put("com.openbravo.pos.reports.JReportUserSales", "/com/openbravo/reports/usersales.bs");
/* 225 */     m_oldclasses.put("com.openbravo.pos.reports.JReportProducts", "/com/openbravo/reports/products.bs");
/* 226 */     m_oldclasses.put("com.openbravo.pos.reports.JReportCatalog", "/com/openbravo/reports/productscatalog.bs");
/*     */ 
/* 229 */     m_oldclasses.put("com.openbravo.pos.panels.JPanelTax", "com.openbravo.pos.inventory.TaxPanel");
/*     */   }
/*     */ 
/*     */   static
/*     */   {
/*  60 */     initOldClasses();
/*     */   }
/*     */ 
/*     */   private class ConfigurationHandler extends DefaultHandler
/*     */   {
/*     */     private ConfigurationHandler()
/*     */     {
/*     */     }
/*     */ 
/*     */     public void startDocument()
/*     */       throws SAXException
/*     */     {
/*     */     }
/*     */ 
/*     */     public void endDocument()
/*     */       throws SAXException
/*     */     {
/*     */     }
/*     */ 
/*     */     public void startElement(String uri, String localName, String qName, Attributes attributes)
/*     */       throws SAXException
/*     */     {
/* 240 */       if ("class".equals(qName))
/* 241 */         AppUser.this.m_apermissions.add(AppUser.access$100(attributes.getValue("name")));
/*     */     }
/*     */ 
/*     */     public void endElement(String uri, String localName, String qName)
/*     */       throws SAXException
/*     */     {
/*     */     }
/*     */ 
/*     */     public void characters(char[] ch, int start, int length)
/*     */       throws SAXException
/*     */     {
/*     */     }
/*     */   }
/*     */
public static String access$100(String value) {
	// TODO Auto-generated method stub
	return null;
} }

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.forms.AppUser
 * JD-Core Version:    0.6.0
 */